<template>
	<view class="register">
		<view class="logobox">
			<image src="../../static/logo.png" mode="" style="margin-top: 40rpx;"></image>
		</view>
		<view class="registerform">

			<view class="formitem fcs border-bottom">
				<view class="textr f14">+86</view><input style="color: #909399;" class="f14" type="number" maxlength="11" placeholder="请输入手机号" v-model="tel" />
			</view>

			<view class="formitem fcs border-bottom">
				<view class="textr f14">登录密码</view> <input style="color: #909399;" class="f14 inputhez" :type="logstate?'text':'password'"    placeholder="请输入登录密码" v-model="loginpassword" />		<image :src="logstate ? '../../static/closeeye.png' : '../../static/openeye.png'" mode="" style="width:36rpx ;height:36rpx ;margin-left: 64rpx;position: absolute;
			    right: 0;" @click="eyesin('logstate')"></image>
			</view>
			</view>
			<navigator class="forgetpasword f12" url="../forgetpassword/forgetpassword">
				忘记密码？
			</navigator>
			<view class="loginbox f18" @click="gotoIndex()">
				登录
			</view>
			<view class="gologinbox f13 text-c">
				<view class="mgr8">
					没有账号?
				</view>
				<view class="login" @click="gotoRegister">
					<view class="mgr8">
						去注册
					</view>
					<image src="../../static/bluearrow.png" mode=""></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				tel:"",
				loginpassword:"",
				logstate: false,
			}
		},
		methods:{
			gotoRegister(){
				uni.reLaunch({
					url:"../register/register"
				})
			},
			eyesin(state) {
				// console.log(1)
				if (state == 'logstate') {
					this.logstate = !this.logstate;
				} else {
					this.passtate = !this.passtate;
				}
			},
		async gotoIndex(){
				if(!/^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/.test(this.tel)){
					uni.showToast({
						title: '请输入手机号',
						icon: 'none'
					});
					return false;
				}
				// if (!/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/.test(this.loginpassword)) {
				// 	uni.showToast({
				// 		title: '请输入最少8位字母+数字',
				// 		icon: 'none'
				// 	});
				// 	return false;
				// }
			let params={
				phone:this.tel,
				password:this.loginpassword
			}
							let res =await this.$http.post('login.login',params,{ isAuth: false, tipConfig: { isLoading: false } })
				// console.log(res)
				uni.setStorageSync('token', res.data.token)
				if(res.code==200){
					setTimeout(() => {
						uni.switchTab({
							url: '../index/index'
						});
					}, 500);	
				}
						
			}
		}
	}
</script>

<style lang="less">
	.inputhez{
		border: none;
		outline: none;
		padding: 0;
	}
	.register{
		margin-top: 140rpx;
		.logobox{
			margin-top: 46rpx;
			margin-left: auto;
			margin-right: auto;
			width: 204rpx;
			height: 278rpx;
			image{
				width:204rpx;
				height: 278rpx;
			}
		}
		.registerform{
			margin-top: 88rpx;
			padding: 0 30rpx;
		}
		input{
			width: 310rpx;
		}
		.forgetpasword{
			margin-top: 32rpx;
			text-align: right;
			font-size: 24rpx;
			padding-right: 30rpx;
			color: #909399;
		}
		.gologinbox{
			display: flex;
			justify-content: center;
			align-items: center;
			margin-top: 60rpx;
			text-align: center;
			margin-left: auto;
			margin-right: auto;
			width: 340rpx;
			// font-size: 36rpx;
			.login{
				display: flex;
				font-size: 26rpx;
				justify-content: space-between;
				align-items: center;
				font-family: PingFangSC, PingFangSC-Regular;
				font-weight: 400;
				color: #1372DF;
				
			}
			image{
				width: 12rpx;
				height:16rpx;
				
			}
		}
		
	}
</style>
